class Solution
{
public:
    bool check(vector<int>& nums, int mid, int max)
    {
        int count = 0;
        for (int& x : nums)
        {
            count += (x + mid - 1) / mid - 1;
        }
        return count > max;
    }

    int minimumSize(vector<int>& nums, int maxOperations)
    {
        int left = 1;
        int right = *max_element(nums.begin(), nums.end());
        while (left <= right)
        {
            int mid = left + (right - left) / 2;
            if (check(nums, mid, maxOperations)) left = mid + 1;
            else right = mid - 1;
        }
        return left;
    }
};